from building import *

cwd = GetCurrentDir()
list = os.listdir(cwd)
objs = []

src = Split('''
	board.c
	drv_uart.c
    pin_map.c
	''')

if GetDepend(['RT_USING_ADC']):
	src += ['drv_adc.c']

if GetDepend(['RT_USING_LWIP']):
	src += ['drv_wifi.c']
		
if GetDepend('RT_USING_PIN'):
    src += ['drv_pin.c']

if GetDepend('RT_USING_SDIO'):
    src += ['drv_sdio.c']

if GetDepend('RT_USING_CAN'):
    src += ['drv_can.c']

if GetDepend('RT_USING_HWTIMER'):
    src += ['drv_hw_timer.c']

if GetDepend('RT_USING_CPUTIME'):
    src += ['drv_cputime.c']

if GetDepend('RT_USING_I2C'):
    src += ['drv_i2c.c']

if GetDepend('RT_USING_SPI'):
    src += ['drv_spi.c']

if GetDepend(['RT_USING_W25QXX']) or GetDepend(['RT_USING_SFUD']):
    src += ['drv_spiflash.c']

if GetDepend('RT_USING_UIENGINE'):
    src += ['drv_lcd.c']

if GetDepend('RT_USING_PWM'):
    src += ['drv_pwm.c']

if GetDepend('RT_USING_RTC'):
    src += ['drv_rtc.c']

if GetDepend('RT_USING_WDT'):
    src += ['drv_wdt.c']
    
CPPPATH = [cwd]

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

for d in list:
    path = os.path.join(cwd, d)
    if os.path.isfile(os.path.join(path, 'SConscript')):
        objs = objs + SConscript(os.path.join(d, 'SConscript'))
objs = objs + group
Return('objs')
